Skip to content

Conversation

@ohah
Copy link
Owner

@ohah ohah commented Oct 28, 2025

리팩토링: deno_core 관련 코드를 독립적인 크레이트로 이동

📋 요약

이 PR은 deno_core 관련 코드를 독립적인 deno-runtime 크레이트로 추출하여 더 나은 코드 조직화와 재사용성을 제공합니다.

🎯 동기

  • 코드 격리: deno_core 관련 기능을 메인 Tauri 애플리케이션에서 분리
  • 재사용성: 다른 프로젝트에서도 사용할 수 있는 독립적인 JavaScript 런타임 제공
  • 유지보수성: 관심사의 분리와 더 쉬운 유지보수
  • 테스트: JavaScript 런타임 기능을 위한 독립적인 테스트 환경

🔄 변경사항

1. crates/deno-runtime 크레이트 생성

  • 새로운 크레이트 구조:

    crates/deno-runtime/
    ├── Cargo.toml          # 독립적인 크레이트 설정
    └── src/
        ├── lib.rs          # DenoExecutor와 ExecutionOutput
        └── bootstrap.js    # JavaScript 런타임 부트스트랩 코드
    
  • 포함된 기능들:

    • V8 기반 JavaScript 런타임을 가진 DenoExecutor 구조체
    • stdout/stderr 관리를 위한 ExecutionOutput
    • 커스텀 JavaScript API (console, alert, require)
    • npm 모듈 시뮬레이션 (lodash, moment, uuid)
    • 포괄적인 테스트 스위트

2. Tauri 애플리케이션 의존성 업데이트

  • 직접적인 deno_core 의존성을 deno-runtime 크레이트로 교체
  • apps/executeJS/src-tauri/Cargo.toml을 로컬 경로 의존성으로 업데이트
  • 동일한 JavaScript 실행 기능 유지

3. import 경로 리팩토링 및 중복 파일 제거

  • apps/executeJS/src-tauri/src/deno_runtime.rs 제거
  • apps/executeJS/src-tauri/src/bootstrap.js 제거
  • js_executor.rs에서 deno-runtime 크레이트로부터 DenoExecutor import하도록 업데이트
  • commands.rsjs_executor.rs에서 사용하지 않는 import 정리
  • lib.rs에서 deno_runtime 모듈 선언 제거

🧪 테스트

모든 기존 기능이 보존되고 테스트되었습니다:

# deno-runtime 크레이트를 독립적으로 테스트
cargo test -p deno-runtime

# 메인 Tauri 애플리케이션 테스트
cargo test -p executeJS

# 빌드가 올바르게 작동하는지 확인
cargo check

테스트 결과: ✅ 모든 테스트 통과 (deno-runtime에서 7개 테스트, executeJS에서 0개 테스트)

📊 영향

이전

apps/executeJS/src-tauri/src/
├── deno_runtime.rs    # Tauri 앱 코드와 혼재
├── bootstrap.js       # JavaScript 런타임 코드
├── js_executor.rs     # JavaScript 실행 로직
└── commands.rs        # Tauri 명령어

이후

crates/deno-runtime/           # 독립적인 크레이트
├── src/lib.rs                 # JavaScript 런타임
└── src/bootstrap.js           # 부트스트랩 코드

apps/executeJS/src-tauri/src/  # 깔끔한 Tauri 앱
├── js_executor.rs             # deno-runtime 크레이트 사용
└── commands.rs                # Tauri 명령어

🔍 코드 품질

  • 호환성 유지: 모든 기존 API가 동일하게 유지됨
  • 깔끔한 분리: JavaScript 런타임 로직이 이제 격리됨
  • 더 나은 조직화: 관련 코드가 함께 그룹화됨
  • 개선된 유지보수성: JavaScript 런타임을 독립적으로 수정하기 쉬움

🚀 이점

  1. 모듈성: JavaScript 런타임을 다른 프로젝트에서 사용 가능
  2. 유지보수성: JavaScript 런타임 기능을 더 쉽게 업데이트하고 테스트
  3. 코드 조직화: Tauri 앱과 JavaScript 런타임 간의 명확한 분리
  4. 재사용성: 다른 Rust 프로젝트에서 deno-runtime 크레이트 사용 가능
  5. 테스트: JavaScript 런타임 기능을 위한 독립적인 테스트 스위트

📝 커밋 히스토리

  • feat: create deno-runtime crate - JavaScript 런타임과 함께 독립적인 크레이트 추가
  • refactor: update Tauri app to use deno-runtime crate - 의존성 업데이트
  • refactor: remove local deno files and update imports - 기존 파일 정리
  • chore: update Cargo.lock for deno-runtime crate - 락 파일 업데이트

✅ 체크리스트

  • 모든 기존 테스트 통과
  • 공개 API에 대한 호환성 유지
  • 코드가 적절히 조직화되고 문서화됨
  • 의존성이 올바르게 설정됨
  • 빌드 시스템이 올바르게 작동함
  • JavaScript 실행 기능이 보존됨

🔗 관련사항

이 리팩토링은 호환성을 유지하면서 코드 조직을 개선하여 JavaScript 런타임의 향후 향상을 위한 기반을 마련합니다.

ohah added 4 commits October 28, 2025 17:32
- Add independent deno-runtime crate for JavaScript execution
- Include DenoExecutor with V8-based JavaScript runtime
- Add bootstrap.js for custom JavaScript APIs (console, alert, require)
- Support npm module simulation (lodash, moment, uuid)
- Include comprehensive test suite for JavaScript execution
- Replace direct deno_core dependency with deno-runtime crate
- Use local path dependency for better code organization
- Maintain same JavaScript execution functionality
- Remove deno_runtime.rs and bootstrap.js from Tauri app
- Update js_executor.rs to import DenoExecutor from deno-runtime crate
- Remove deno_runtime module declaration from lib.rs
- Clean up unused imports in commands.rs and js_executor.rs
- Maintain same JavaScript execution API
- Update dependency lock file to reflect new crate structure
- Ensure reproducible builds with new deno-runtime dependency
@ohah ohah self-assigned this Oct 28, 2025
@ohah ohah added the refactor label Oct 28, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors deno_core related code into an independent deno-runtime crate to improve code organization and reusability. The JavaScript runtime is now isolated from the main Tauri application, enabling better maintainability and potential reuse in other projects.

Key Changes:

  • Created a new deno-runtime crate with DenoExecutor and bootstrap JavaScript code
  • Updated Tauri application to depend on the new crate instead of direct deno_core dependency
  • Cleaned up unused imports and removed duplicate files from the Tauri application

Reviewed Changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/deno-runtime/Cargo.toml New crate configuration with deno_core 0.323 dependency
crates/deno-runtime/src/bootstrap.js Formatting improvements to uuid and error throwing logic
apps/executeJS/src-tauri/Cargo.toml Replaced direct deno_core dependency with local deno-runtime crate
apps/executeJS/src-tauri/src/lib.rs Removed deno_runtime module declaration
apps/executeJS/src-tauri/src/js_executor.rs Updated import path and removed unused imports
apps/executeJS/src-tauri/src/commands.rs Removed unused tauri::State import

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ohah
Copy link
Owner Author

ohah commented Oct 28, 2025

deno 코드 추가하기전에 한곳으로 일단 몰아넣었어요

@ohah ohah merged commit f750e8e into main Oct 28, 2025
1 check passed
ohah added a commit that referenced this pull request Dec 12, 2025
# 리팩토링: deno_core 관련 코드를 독립적인 크레이트로 이동
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants